<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML>
<%@include file="/common/taglibs.jsp" %>
<%@include file="/common/javascript.jsp" %>
<html>
<head>
<meta charset="utf-8">
<title>土地计划</title>
	
    <script type="text/javascript">
		
		$(function(){
			
			$("#dg").datagrid({url:'landGrid?land.type=3',rownumbers:true,singleSelect:false,selectOnCheck:true,
					fitColumns:true,pagination:true,loadMsg:'数据加载中...',pageSize:10,pageList:[10,20,30],
					frozenColumns:[[     
                  		{field:'ck',checkbox:true}
            		]],
					columns:[[  
						{field:'id',title:"序号",width:50,align:'center',hidden:true}, 
						{field:'num',title:"编号",width:100,align:'center'},
						{field:'name',title:"地块名称",width:100,align:'center'},
						{field:'location',title:"土地坐落",width:100,align:'center'},
						{field:'purpose',title:"土地用途",width:100,align:'center'},
						{field:'square',title:"土地面积(平米)",width:150,align:'center'}, 
						{field:'capacity',title:"容积率",width:80,align:'center'},
						{field:'initPrice',title:"起始价格(元)",width:150,align:'center'},
						{field:'transPrice',title:"成交价格(元)",width:150,align:'center'},
						{field:'bidder',title:"竞得人",width:100,align:'center'},
						{field:'transDate',title:"成交日期",width:100,align:'center'},
						{field:'remark',title:"备注",width:100,align:'center'},
						{field:'attach',title:"附件",width:100,align:'center'},
						{field:'area',title:"区位",width:80,align:'center'}
					]]  
			});
			
			$("#dg").datagrid('getPager').pagination({//分页栏下方文字显示
				showPageList:false,
				beforePageText:'第',
				afterPageText: '页    共 {pages} 页',            
			    displayMsg:'当前显示   从第{from}条到{to}条     共{total}条记录'
			});
			
			$("#btnAddP").bind('click',function(){
				var rows=$("#dg").datagrid('getSelections');
				if(rows && rows.length>1){
					$.messager.alert('提示','请选择单一数据项',"info");
				}else{
					var row =$("#dg").datagrid('getSelected');
					if(row){
					    pageLoading(window.frames["openFrame"].document);
						$("#openFrame")[0].src="landAction_gotoLandAtta?land.id="+row.id;
						$("#content").dialog({ title:'添加附件', width:610, height:200, closed:true, minimizable:true, maximizable:true,modal:true,
							buttons:[{
							  text:'保存',
									handler:function(){
										 openFrame.window.saveInfo();
									}
								},{
									text:'关闭',
									handler:function(){
										$("#content").dialog('close');
									}
								}]
						});
						$("#content").dialog('open');
					}else{
						$.messager.alert('提示','请先选择要添加的数据项',"info");
					}	
				}
			});
				
			$("#btnAdd").bind('click',function(){
				pageLoading(window.frames["openFrame"].document);
				$("#openFrame")[0].src="landAction_gotoLandTranForm.action?viewType=add";
				$("#content").dialog({ title:'新增土地成交', width:630, height:400, closed:true, minimizable:true, maximizable:true, modal:true,
					buttons:[{
					  text:'保存',
							handler:function(){
							  
								 openFrame.window.saveInfo();
								 
							}
						},{
							text:'关闭',
							handler:function(){
								$("#content").dialog('close');
							}
						}]
				});
				$("#content").dialog('open');
			});
			
			$("#btnEdit").bind('click',function(){
				var rows=$("#dg").datagrid('getSelections');
				if(rows && rows.length>1){
					$.messager.alert('提示','请选择单一数据项修改',"info");
				}else{
					var row =$("#dg").datagrid('getSelected');
					if(row){
					    pageLoading(window.frames["openFrame"].document);
						$("#openFrame")[0].src="landAction_gotoLandTranForm?viewType=modify&land.id="+row.id;
						$("#content").dialog({ title:'修改', width:630, height:400, closed:true, minimizable:true, maximizable:true,modal:true,
							buttons:[{
							  text:'保存',
									handler:function(){
										 openFrame.window.saveInfo();
									}
								},{
									text:'关闭',
									handler:function(){
										$("#content").dialog('close');
									}
								}]
						});
						$("#content").dialog('open');
					}else{
						$.messager.alert('提示','请先选择要修改的数据项',"info");
					}	
				}
			});
			
			$("#btnDetail").bind('click',function(){
				var rows=$("#dg").datagrid('getSelections');
				if(rows && rows.length>1){
					$.messager.alert('提示','请选择单一数据项修改',"info");
				}else{
					var row =$("#dg").datagrid('getSelected');
					if(row){
					    pageLoading(window.frames["openFrame"].document);
						$("#openFrame")[0].src="landAction_gotoLandTranForm?viewType=detail&land.id="+row.id;
						$("#content").dialog({ title:'详情', width:630, height:400, closed:true, minimizable:true, maximizable:true,modal:true,
							buttons:[{
									text:'关闭',
									handler:function(){
										$("#content").dialog('close');
									}
								}]
						});
						$("#content").dialog('open');
					}else{
						$.messager.alert('提示','请先选择要修改的数据项',"info");
					}	
				}
			});
			
			$("#btnDelete").bind('click',function(){
				var rows=$("#dg").datagrid('getSelections');
				if(rows!=null && rows.length>0){
					$.messager.confirm('提示','确定要删除吗？',function(r){
						if (r){  
							var ids="";
							for(var i=0;i<rows.length;i++){
								ids+=rows[i].id+",";
							}
							$.post("landAction_delete",{ids:ids},function(data){
								var data = eval('(' + data + ')');
								if (!data.success){ //删除失败  
									$.messager.alert('提示',"错误"+data.message,"info");
        						}else{//删除成功
        							$.messager.alert('提示',data.message,"info",function(){
        								$('#dg').datagrid('reload'); //刷新网格
        							});
        						} 
							});
						}
					});
				}else{
					$.messager.alert('提示','请先选择要删除的数据项',"info");
				}
			});
			
			$("#btnView").bind('click',function(){
				var rows=$("#dg").datagrid('getSelections');
				if(rows && rows.length>1){
					window.parent.window.$.messager.alert('提示','请选择单一数据项修改',"info");
				}else{
					var row =$("#dg").datagrid('getSelected');
					if(row){
						parent.window.addTab('查看地图','mapAction_locationUI?viewType=loc&type=3&ltype=3&id='+row.id,'');
					}else{
						window.parent.window.$.messager.alert('提示','请先选择相应的项目',"info");
					}
				}
			});
			
			var area=$("#comArea").val(); //查询行政区
			
			$("#comArea").combobox({
				onChange:function(newValue,oldValue){  
					area=newValue;
				}  
			});
			
			$("#btnSearch").bind('click',function(){
				if(!isNull('start')) return; //验证日期是否为空
				if(!isNull('end')) return; //验证日期是否为空
				if(!checkdate('start','end')) return;
				$('#dg').datagrid('load',{
					viewType:'query',regionId:area,startDate:$("#start").val(),endDate:$("#end").val()
				});
			});
		});
		
		function closeContent(){
			$("#content").dialog('close');
			$('#dg').datagrid('reload');
		}
		
		function viewAttas(obj,id){
			pageLoading(window.frames["openFrame"].document);
			$("#openFrame")[0].src="landAction_gotoAttachList?land.id="+id;
			$("#content").dialog({ title:'查看附件', width:610, height:300, closed:true, 
				minimizable:true, modal:true,resizable:true,
				buttons:[{
					text:'关闭',
					handler:function(){
						$("#content").dialog('close');
					}
				}]
			});
			$("#content").dialog('open');
		}
		
		function openMarker(url,title){
			pageLoading(window.frames["childOpenFrame"].document);
			$("#childOpenFrame")[0].src=url;
			$("#childContent").dialog({ title:title, width:300, height:200,  closed:false,
				maximizable:true,minimizable:true,modal:true,resizable:true,
				buttons:[{
					text:'确定',
						handler:function(){
							childOpenFrame.window.getMarker();
							$("#childContent").dialog('close');
						}
					},{
					text:'关闭',
					handler:function(){
						$("#childContent").dialog('close');
					}
				}]
			});
			$("#childContent").dialog('open');
		}
		
		function openMap(url,title){
			pageLoading(window.frames["childOpenFrame"].document);
			$("#childOpenFrame")[0].src=url;
			$("#childContent").dialog({ title:title, width:800, height:400,  closed:false,
				maximizable:true,minimizable:true,modal:true,resizable:true,
				buttons:[{
					text:'重绘',
						handler:function(){
							childOpenFrame.window.clear();
						}
					},{
					text:'确定',
						handler:function(){
							childOpenFrame.window.submit();
							$("#childContent").dialog('close');
						}
					},{
					text:'关闭',
					handler:function(){
						$("#childContent").dialog('close');
					}
				}]
			});
			$("#childContent").dialog('open');
		}
		function setLonlat(e){
			openFrame.window.setLonlat(e);
		}
		function setArea(str,center){
			openFrame.window.setArea(str,center);
		}
		function setMarkerName(e){
			openFrame.window.setMarkerName(e);
		}
	</script>
</head>

<body style="margin:0px; overflow-style:clear; padding:0px;">
	<div data-options="region:'north',border:false" style="height:40px;padding:0px;margin:0px;" id="mainsearch">
    	<div style="padding:10px;" id="formsearch">
            	行政区<select id="comArea" class="easyui-combobox" name="comArea" style="width:80px; text-align:center">  
                    <option value="-1">--请选择--</option>
                             <s:iterator value="areas">
                             <option value='<s:property value="key"/>'><s:property value="value"/></option>
                             
                             </s:iterator>
						</select> 
            	开始时间：<input id="start" name="start" type="text" class="Wdate" onclick="WdatePicker({skin:'whyGreen'})"
                			value='<s:date name="model.dateCre" format="yyyy-MM-dd"/>'  />
                                                结束时间：<input id="end" name="end" type="text" class="Wdate" onclick="WdatePicker({skin:'whyGreen'})"
                			value='<s:date name="model.dateCre" format="yyyy-MM-dd"/>'  />
                <a id="btnSearch"  class="easyui-linkbutton" data-options="iconCls:'icon-search'">查询</a>
        </div>
    </div>
    
    <div id="toolbar" style="background:#C9DFFF">
    	<c:if test="${permissionId==1}">
    		<a id="btnAdd"  class="easyui-linkbutton" data-options="iconCls:'icon-add',plain:'true'" style="text-align:center">增加</a>
        	<a id="btnEdit" class="easyui-linkbutton" data-options="iconCls:'icon-edit',plain:'true'" style="text-align:center">修改</a>
        	<a id="btnDelete" class="easyui-linkbutton" data-options="iconCls:'icon-delete',plain:'true'" style="text-align:center">删除</a>
    	     <a id="btnAddP"  class="easyui-linkbutton" data-options="iconCls:'icon-add',plain:'true'" style="text-align:center">添加附件</a>
    	</c:if>
    	<a id="btnDetail" class="easyui-linkbutton" data-options="iconCls:'icon-detail',plain:'true'" style="text-align:center">详情</a>
        <a id="btnView" class="easyui-linkbutton" data-options="iconCls:'icon-detail',plain:'true'" style="text-align:center">查看地图</a>
    </div>
    <table id="dg"> </table>
    
    <div id="content">
    	<iframe id='openFrame' name='openFrame' frameborder="0" scrolling="no"  src="" style="width:100%;height:95%;"></iframe> 
    </div> 
    <div id="childContent">
    	<iframe id="childOpenFrame" name="childOpenFrame" frameborder="0"  src="" style="width:100%;height:98%;"></iframe>
    </div>
</body>
</html>
